﻿using System.Collections.Generic;
using NUnit.Framework;
using wpffc.contracts.domaindata;
using wpffc.flashcardbox.domaindata;

namespace wpffc.flashcardbox.tests.domaindata
{
    [TestFixture]
    public class test_Batch
    {
        [Test]
        public void Enqueue_card()
        {
            var q = new Queue<BatchCard>();
            var sut = new Batch(q, 0, 0);
            var c = new BatchCard();

            sut.Enqueue(c);

            Assert.AreEqual(1, q.Count);
            Assert.AreSame(c, q.Dequeue());
        }


        [Test]
        public void Dequeue_card()
        {
            var q = new Queue<BatchCard>();
            var sut = new Batch(q, 0, 0);

            var c = new BatchCard();
            q.Enqueue(c);

            var d = sut.Dequeue();

            Assert.AreSame(c, d);
            Assert.AreEqual(0, q.Count);
        }


        [Test]
        public void Peek_at_card()
        {
            var q = new Queue<BatchCard>();
            var sut = new Batch(q, 0, 0);

            var c = new BatchCard();
            q.Enqueue(c);

            var d = sut.Peek();

            Assert.AreSame(c, d);
            Assert.AreEqual(1, q.Count);
        }


        [Test]
        public void Status_changes()
        {
            var q = new Queue<BatchCard>();
            var sut = new Batch(q, 1, 3);

            Assert.AreEqual(BatchStatus.Empty, sut.Status);

            sut.Enqueue(new BatchCard());
            Assert.AreEqual(BatchStatus.NeedsRefill, sut.Status);

            sut.Enqueue(new BatchCard());
            Assert.AreEqual(BatchStatus.Filled, sut.Status);

            sut.Enqueue(new BatchCard());
            Assert.AreEqual(BatchStatus.Full, sut.Status);
        }
    }
}
